#pragma once
#include "inputinterface.h"
#include <dinput.h>

namespace engine{
	class Keyboard :
		public DeviceInterface
	{
		static const int KEY_SIZE = 256; 
	public:
		Keyboard(LPDIRECTINPUT8 input, HWND hwnd);
		virtual ~Keyboard(void);

		virtual bool UpdateDevice();

		virtual int ButtonUp(unsigned int key);
		virtual int ButtonDown(unsigned int key);

		virtual POINT GetPosition();
		virtual POINT GetZPosition();

		virtual void Shutdown();

	private:
		LPDIRECTINPUTDEVICE8 m_Device;
		char m_Keys[KEY_SIZE];
		char m_OldKeys[KEY_SIZE];
	};

	class Mouse :
		public DeviceInterface
	{
	public:
		Mouse(LPDIRECTINPUT8 input, HWND hwnd, bool exclusive);
		virtual ~Mouse(); 

		bool UpdateDevice();

		int ButtonUp(unsigned int key);
		int ButtonDown(unsigned int key);

		POINT GetPosition();
		POINT GetZPosition();

		void Shutdown();
	private:
		LPDIRECTINPUTDEVICE8 m_Device;
		DIMOUSESTATE m_MouseState;
		DIMOUSESTATE m_OldMouseState;

		bool m_Button[3];

		long m_Xpos;
		long m_Ypos;
		long m_Zpos;

		bool m_Restrict;
		int m_Width;
		int m__Height;

	};

	class DirectInput :
		public InputInterface
	{
	public:
		DirectInput();
		virtual~DirectInput(void);

		virtual bool Initialize(HWND hwnd, HINSTANCE hInst, bool exclusive);
		virtual bool UpdateDevices();

		virtual int KeyUp(unsigned int key);
		virtual int KeyDown(unsigned int key);

		virtual int MouseButtonUp(unsigned int button);
		virtual int MouseButtonDown(unsigned int button);
		virtual POINT GetMousePos();
		virtual long GetMouseWheelPos();

		virtual int ControllerButtonUp(unsigned int button);
		virtual int ControllerButtonDown(unsigned int button);
		virtual POINT GetLeftStickPos();
		virtual POINT GetRightStickPos();

		virtual void Shutdown();

	private:
		LPDIRECTINPUT8 m_System;
		Keyboard* m_Keyboard;
		Mouse* m_Mouse;
	};

}